package Day2_2;

import jdk.nashorn.internal.ir.IfNode;

import java.util.Scanner;

public class APItest {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String[] pass=new String[]{"TMD","共产党"};
        System.out.println("请输入聊天内容");
        String nextLine=scanner.nextLine();




        for (int i=0;i<pass.length;i++){
            if (nextLine.contains(pass[i])){
                System.out.println("包含");

                //indexof 寻找字符串中某个元素的位置
                int index=nextLine.indexOf("TMD");
                System.out.println("TMD的位置在"+index);

                //replace 替换字符
                //进行敏感词替换
                String replace=nextLine.replace(pass[i],"***");
                System.out.println("新的字符串为"+replace);

                int index2=nextLine.indexOf("886");
                System.out.println("886位置"+index2);
                //字符串的 剪切
                String substring=nextLine.substring(index2);
                System.out.println(substring);
            }
        }
    }
}
